package com.example.backspring.controller;

import com.example.backspring.Service.StudentService;
import com.example.backspring.config.Message;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/registe")
@Tag(name = "注册与登录", description = "用户注册和登录接口")
public class Registe {
    @Resource
    private StudentService studentService;

    @PostMapping("/person")
    @Operation(summary = "用户登录", description = "根据用户名和密码进行用户登录")
    public Message login(@RequestParam String username, @RequestParam String pwd) {
        log.info("接收到登录信息");
        Message result = studentService.Login(username, pwd);
        return result;
    }

    @PostMapping("/user")
    @Operation(summary = "用户注册", description = "根据用户名和密码进行用户注册")
    public Message registe(@RequestParam String username, @RequestParam String pwd) {
        log.info("接收到的账户名: " + username);
        log.info("接收到的密码: " + pwd);
        String wewe = studentService.RegisteUser(username, pwd);
        Message result = new Message(true, wewe, 1);
        return result;
    }
}
